﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            

            yanghui();
        }







        //下标
        static void xb(string [] a)
        {
            int index = 0;
            foreach (var item in a)
            {
              
                if (index%2==0)
                {
                    Console.Write(item);

                }
                index++;
            }


            Console.WriteLine();

        }

            //数组排序
            static void szpx()
        {
            int[] a = new int[6];


            a[0] = 99;
            a[1] = 55;
            a[2] = 44;
            a[3] = 33;
            a[4] = 11;


            Console.WriteLine("请输入你要添加的数字：");
             a[5]=int.Parse(Console.ReadLine());

            Array.Sort(a);
            Array.Reverse(a);

            foreach (var item in a)
            {
                Console.Write("["+item+"] ");
            }


            Console.WriteLine();
        }

            //九九乘法表

            static void jjb()
        {

            string[,] a = new string[9,9];

            for (int i = 1; i <a.GetLength(0)+1; i++)
            {
                for (int j = 1; j <a.GetLength(1)+1 ; j++)
                {
                    if (i>=j)
                    {
                        a[i-1, j-1] = i + "*" + j + "=" +i *j +"\t";

                    }
                    else
                    {
                        a[i-1, j-1] = "";
                    }

                }

            }

            for (int i = 1; i < a.GetLength(0)+1; i++)
            {
                for (int j = 1; j < a.GetLength(1)+1; j++)
                {
                    Console.Write(a[i-1,j-1]);

                }
                Console.WriteLine();
            }





        }


        //实心正方形
        static void sxzfx()
        {

            Console.WriteLine("请输入正方形的长：");
            int b = int.Parse(Console.ReadLine());


            int[,] a = new int[b, b];


            for (int i = 0; i < b; i++)
            {
                for (int j = 0; j < b; j++)
                {
                    a[i, j] = 1;

                }
            }


            for (int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j < a.GetLength(1); j++)
                {
                    if (a[i, j] == 1)
                    {
                        Console.Write("*");
                    }
                    else
                    {
                        Console.Write(" ");
                    }


                }
                Console.WriteLine();
            }



        }

        //空心正方形
        static void kxzfx()
        {
            Console.WriteLine("请输入正方形的长：");
            int a = int.Parse(Console.ReadLine());

            int[,] b = new int[a, a];


            for (int i = 0; i < b.GetLength(0); i++)
            {
                for (int j = 0; j < b.GetLength(1); j++)
                {
                    if (i == 0 || i == a - 1)
                    {

                        b[i, j] = 1;
                    }
                    else


                    if (i > 0 && i < a && j == 0 || j == a - 1)
                    {
                        b[i, j] = 1;
                    }

                }


            }

            for (int i = 0; i < b.GetLength(0); i++)
            {
                for (int j = 0; j < b.GetLength(1); j++)
                {
                    if (b[i, j] == 1)
                    {
                        Console.Write("*");
                    }
                    else
                    {
                        Console.Write(" ");
                    }


                }
                Console.WriteLine();
            }
        }


        //菱形
        static void lx()
        {

            Console.WriteLine("请输入菱形边长：");
            int b = int.Parse(Console.ReadLine());

            int[,] a = new int[b*2-1, 2 * b - 1];

            for (int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j < a.GetLength(1); j++)
                {
                    if (i == 0 || i == b*2-1)
                    {
                        if (j == b - 1)
                        {
                            a[i, j] = 1;
                        }


                    }
                    else if (i <= b-1 )
                    {
                        if (j <= b - 1 + i && j >= b - 1 - i)
                        {
                            a[i, j] = 1;
                        }
                    }
                    else 

                    {
                        if (j >=  i-b+1 && j <= 2*b-1-(i-b+2))
                        {
                            a[i, j] = 1;
                        }


                    }

                }


            }


            for (int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j < a.GetLength(1); j++)
                {
                    if (a[i, j] == 1)
                    {
                        Console.Write("*");
                    }
                    else
                    {
                        Console.Write(" ");
                    }


                }
                Console.WriteLine();
            }
        
        }





            //杨辉三角
            static void yanghui()
    {

        int[,] a = new int[10, 19];

        for (int i = 0; i < a.GetLength(0); i++)
        {
            for (int j = 0; j < a.GetLength(1); j++)
            {

                if (i == 0)
                {


                    if (i == 0 && j == 9)
                    {
                        a[i, j] = 1;
                    }

                }
                else if (i > 0)

                {
                    if (j <= 16 && j < 9 + i && j > 9 - i)
                    {
                        a[i, j] = a[i - 1, j - 1] + a[i - 1, j + 1];



                    }
                    else
                      if (j == 9 + i || j == 9 - i)
                    {
                        a[i, j] = 1;
                    }



                }







            }

        }

        for (int i = 0; i < a.GetLength(0); i++)
        {
            for (int j = 0; j < a.GetLength(1); j++)
            {


                if (a[i, j] != 0)
                {

                    Console.Write(a[i, j]+" ");

                }
                else
                {
                    Console.Write("  ");
                }

            }
            Console.WriteLine();
        }
    
        }
    }
}
